From 82e49952e5c81cb9f42af3480569c85cc9411921 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Timm=20B=C3=A4der?= Date: Sun, 22 Jan 2017 15:01:40 +0100 Subject: [PATCH] flowbox: Measure child widget sizes using gtk_widget_measure --- gtk/gtkflowbox.c | 47 +++++++++++++++-------------------------------- 1 file changed, 15 insertions(+), 32 deletions(-) diff --git a/gtk/gtkflowbox.c b/gtk/gtkflowbox.c index a014e491e6..9c496e8ef0 100644 --- a/gtk/gtkflowbox.c +++ b/gtk/gtkflowbox.c @@ -1267,10 +1267,9 @@ get_max_item_size (GtkFlowBox *box, if (!child_is_visible (child)) continue; - if (orientation == GTK_ORIENTATION_HORIZONTAL) - gtk_widget_get_preferred_width (child, &child_min, &child_nat); - else - gtk_widget_get_preferred_height (child, &child_min, &child_nat); + gtk_widget_measure (child, orientation, -1, + &child_min, &child_nat, + NULL, NULL); max_min_size = MAX (max_min_size, child_min); max_nat_size = MAX (max_nat_size, child_nat); @@ -1310,14 +1309,9 @@ get_largest_size_for_opposing_orientation (GtkFlowBox *box, if (!child_is_visible (child)) continue; - if (orientation == GTK_ORIENTATION_HORIZONTAL) - gtk_widget_get_preferred_height_for_width (child, - item_size, - &child_min, &child_nat); - else - gtk_widget_get_preferred_width_for_height (child, - item_size, - &child_min, &child_nat); + gtk_widget_measure (child, 1 - orientation, item_size, + &child_min, &child_nat, + NULL, NULL); max_min_size = MAX (max_min_size, child_min); max_nat_size = MAX (max_nat_size, child_nat); @@ -1371,14 +1365,9 @@ get_largest_size_for_line_in_opposing_orientation (GtkFlowBox *box, extra_pixels--; } - if (orientation == GTK_ORIENTATION_HORIZONTAL) - gtk_widget_get_preferred_height_for_width (child, - this_item_size, - &child_min, &child_nat); - else - gtk_widget_get_preferred_width_for_height (child, - this_item_size, - &child_min, &child_nat); + gtk_widget_measure (child, 1 - orientation, this_item_size, + &child_min, &child_nat, + NULL, NULL); max_min_size = MAX (max_min_size, child_min); max_nat_size = MAX (max_nat_size, child_nat); @@ -1426,12 +1415,9 @@ gather_aligned_item_requests (GtkFlowBox *box, if (!child_is_visible (child)) continue; - if (orientation == GTK_ORIENTATION_HORIZONTAL) - gtk_widget_get_preferred_width (child, - &child_min, &child_nat); - else - gtk_widget_get_preferred_height (child, - &child_min, &child_nat); + gtk_widget_measure (child, orientation, -1, + &child_min, &child_nat, + NULL, NULL); /* Get the index and push it over for the last line when spreading to the end */ position = i % line_length; @@ -1970,12 +1956,9 @@ get_largest_aligned_line_length (GtkFlowBox *box, if (!child_is_visible (child)) continue; - if (orientation == GTK_ORIENTATION_HORIZONTAL) - gtk_widget_get_preferred_width (child, - &child_min, &child_nat); - else /* GTK_ORIENTATION_VERTICAL */ - gtk_widget_get_preferred_height (child, - &child_min, &child_nat); + gtk_widget_measure (child, orientation, -1, + &child_min, &child_nat, + NULL, NULL); aligned_item_sizes[i % line_length].minimum_size = MAX (aligned_item_sizes[i % line_length].minimum_size, child_min); -- 2.30.2